#define _CRT_SECURE_NO_WARNINGS 1
#include"Aset.h"
void CreateSet(Aset* pa, int a[], int n)
{
	int i = 0;
	for (i = 0; i < n; i++)
	{
		pa->data[i] = a[i];
	}
	pa->length = n;
}
void DispSet(Aset a)
{
	int i = 0;
	for ( i = 0; i < a.length; i++)
	{
		printf("%d ",a.data[i]);
	}
	printf("\n");
}
int InAset(Aset s, int e)
{
	int i = 0;
	for (i = 0; i < s.length; i++)
	{
		if (s.data[i] == e)
		{
			return 1;
		}
	}
	return 0;
}
void Add(Aset a1, Aset a2, Aset* psum)
{
	int i = 0;
	for (i = 0; i < a1.length; i++)
	{
		psum->data[i] = a1.data[i];
	}
	psum->length = a1.length;
	for (i = 0; i < a2.length; i++)
	{
		if (!InAset(a1, a2.data[i]))
		{
			psum->data[psum->length] = a2.data[i];
			psum->length++;
		}
	}
}
//s1-s2
void sub(Aset s1, Aset s2, Aset* sub)
{
	int i = 0; 
	int count = 0;
	for (i = 0; i < s1.length; i++)
	{
		if (!InAset(s2, s1.data[i]))
		{
			sub->data[count] = s1.data[i];
			count++;
		}
	}
	sub->length = count;
}
void intersection(Aset s1, Aset s2, Aset* inter)
{
	int i = 0;
	int count = 0;
	for (i = 0; i < s1.length; i++)
	{
		if (InAset(s2, s1.data[i]))
		{
			inter->data[count] = s1.data[i];
			count++;
		}
	}
	inter->length = count;
}